home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / usr / include / python2.4 / tupleobject.h < prev    next >
Encoding:
C/C++ Source or Header  |  2005-10-18  |  2.0 KB  |  58 lines

  1.  
  2. /* Tuple object interface */
  3.  
  4. #ifndef Py_TUPLEOBJECT_H
  5. #define Py_TUPLEOBJECT_H
  6. #ifdef __cplusplus
  7. extern "C" {
  8. #endif
  9.  
  10. /*
  11. Another generally useful object type is a tuple of object pointers.
  12. For Python, this is an immutable type.  C code can change the tuple items
  13. (but not their number), and even use tuples are general-purpose arrays of
  14. object references, but in general only brand new tuples should be mutated,
  15. not ones that might already have been exposed to Python code.
  16.  
  17. *** WARNING *** PyTuple_SetItem does not increment the new item's reference
  18. count, but does decrement the reference count of the item it replaces,
  19. if not nil.  It does *decrement* the reference count if it is *not*
  20. inserted in the tuple.  Similarly, PyTuple_GetItem does not increment the
  21. returned item's reference count.
  22. */
  23.  
  24. typedef struct {
  25.     PyObject_VAR_HEAD
  26.     PyObject *ob_item[1];
  27.  
  28.     /* ob_item contains space for 'ob_size' elements.
  29.      * Items must normally not be NULL, except during construction when
  30.      * the tuple is not yet visible outside the function that builds it.
  31.      */
  32. } PyTupleObject;
  33.  
  34. PyAPI_DATA(PyTypeObject) PyTuple_Type;
  35.  
  36. #define PyTuple_Check(op) PyObject_TypeCheck(op, &PyTuple_Type)
  37. #define PyTuple_CheckExact(op) ((op)->ob_type == &PyTuple_Type)
  38.  
  39. PyAPI_FUNC(PyObject *) PyTuple_New(int size);
  40. PyAPI_FUNC(int) PyTuple_Size(PyObject *);
  41. PyAPI_FUNC(PyObject *) PyTuple_GetItem(PyObject *, int);
  42. PyAPI_FUNC(int) PyTuple_SetItem(PyObject *, int, PyObject *);
  43. PyAPI_FUNC(PyObject *) PyTuple_GetSlice(PyObject *, int, int);
  44. PyAPI_FUNC(int) _PyTuple_Resize(PyObject **, int);
  45. PyAPI_FUNC(PyObject *) PyTuple_Pack(int, ...);
  46.  
  47. /* Macro, trading safety for speed */
  48. #define PyTuple_GET_ITEM(op, i) (((PyTupleObject *)(op))->ob_item[i])
  49. #define PyTuple_GET_SIZE(op)    (((PyTupleObject *)(op))->ob_size)
  50.  
  51. /* Macro, *only* to be used to fill in brand new tuples */
  52. #define PyTuple_SET_ITEM(op, i, v) (((PyTupleObject *)(op))->ob_item[i] = v)
  53.  
  54. #ifdef __cplusplus
  55. }
  56. #endif
  57. #endif /* !Py_TUPLEOBJECT_H */
  58.